<script setup lang="ts">
	//售后详情
	import { reactive, ref } from "vue";
	import {
		useRouter
	} from 'uni-mini-router'
	import {
		getCurrentInstance
	} from 'vue'
	import {
		onShow,
		onHide,
		onLoad,
		onReachBottom
	} from '@dcloudio/uni-app'
	import {
		userStore
	} from '@/pinia';
	let router = useRouter()
	const userStoreInfo = userStore();
	const {
		proxy,
	} = getCurrentInstance()
	let itemObj = ref(null)
	onLoad((option) => {
		itemObj.value = JSON.parse(option.item)
		console.log(JSON.parse(option.item));
	})
	onShow(() => {
		getDetail()
	})
	const getDetail = () => {
		proxy.$req('GET', proxy.$api.orderDetail, {
			id: itemObj.value.id,
		}).then((res) => {
			console.log(res);
			itemObj.value = res.result
		})
	}
	const routerLink = (e) => {
		router.push({
			name: e,
			params: {
				data: JSON.stringify(itemObj.value)
			}
		})
	}
	let form = ref({
		num: '',
		company: '',
	})
	let list = ref([])
	/*
	1商家处理
	2寄回商品
	3寄件中
	4退款失败
	5退款成功
	*/
	// let orderStatus = ref(2)
	const copy = (e) => {
		uni.setClipboardData({
			data: e,
			success: function () {
				console.log('success');
			}
		});
	}
	const closeShou = (e) => {
		//取消售后
		console.log(e);
		proxy.$req('POST', proxy.$api.closeShou, {
			orderId: e,
			refundStatus: -1
		}).then((res) => {
			console.log(res);
			uni.$u.toast(res.message)
			if (res.success) {
				uni.navigateBack({
					delta: 1
				})
			}
		})
	}
</script>
<template>
	<view class="" v-if="itemObj!=null">
		<view class="step1" v-if="itemObj.refundStatus==1||itemObj.refundStatus==2">
			<view class="timeline">
				<u-steps :current="itemObj.refundStatus" direction="column" dot active-color="#CB645E">
					<u-steps-item title="提交申请">
						<template #desc>
							<view style="color: #b6b6b6;font-size: 26rpx;padding-bottom: 50rpx;"></view>
						</template>
					</u-steps-item>
					<u-steps-item title="商家处理" current="456">
						<template #desc>
							<view style="color: #b6b6b6;font-size: 26rpx;width: 540rpx;">
								如商家同意后，请按照给出的退货地址退货，并请记录退货运单号<br />
								如商家拒绝，您可以修改申请后再次发起，商家会重新处理<br />
								如商家超时未处理，退货申请将达成，请按系统给出的退货地址退货</view>
						</template>
					</u-steps-item>
					<u-steps-item title="寄回商品">
					</u-steps-item>
				</u-steps>
			</view>
		</view>
		<!-- 处理进度处理说明 -->
		<view class="" v-if="itemObj.refundStatus==1||itemObj.refundStatus==2">
			<view class="fTit">
				<text>处理进度</text>
				<text>
					{{ itemObj.refundStatus==1?'申请中':'' }}
					{{ itemObj.refundStatus==2?'已同意':'' }}
				</text>
			</view>
			<view class="fTit" v-if="itemObj.orderInfoList[0].refund.refuseReason">
				<text>处理说明</text>
				<text>{{ itemObj.orderInfoList[0].refund.refuseReason }}</text>
			</view>
		</view>
		<!-- 商品卡片 -->
		<view class="boxAll" v-if="itemObj.refundStatus==2">
			<view class="con" v-for="(it,key) in itemObj.orderInfoList" :key="key">
				<image class="conL" :src="it.sku!=null?it.sku.logo:''" mode=""></image>
				<view class="conR">
					<view class="rl c-flex-center-start">
						<text class="u-line-1" style="font-size: 28rpx;font-weight: 500;">{{ it.productName }}</text>
						<text
							style="font-size: 24rpx;color: rgba(0,0,0,0.45);padding-left: 32rpx;margin-top: 14rpx;">规格：{{ it.sku!=null?it.sku.specIdsName:'' }}</text>
					</view>
					<view class="rr">
						<text class="intFont"><text style="font-size: 20rpx;">￥</text> {{ it.price }}</text>
						<text>×{{ it.cartNum }}</text>
					</view>
				</view>
			</view>
		</view>
		<view class="" v-if="itemObj.refundStatus==2">
			<view class="addressInfo">
				<view class="addTit">
					收件信息
				</view>
				<view class="c-flex-center-start con">
					<view class="conItem">
						<text>联系人：</text>
						<text>{{ itemObj.orderInfoList[0].refund.contactsUser }}</text>
					</view>
					<view class="conItem">
						<text>联系电话：</text>
						<text>{{ itemObj.orderInfoList[0].refund.contactsPhone }}</text>
					</view>
					<view class="conItem">
						<text>收货地址：</text>
						<text>{{ itemObj.orderInfoList[0].refund.contactsAddress }}</text>
					</view>
				</view>
				<view class="r-flex-between-center inputNum">
					<text>我已寄出</text>
					<text @click="routerLink('inputOrderNum')">填写单号</text>
				</view>
				<view class="proofMsg c-flex-center-start">
					<text>退款原因： {{ itemObj.orderInfoList[0].refund.refundReasonWap }}</text>
					<text>退款金额： ￥{{ itemObj.orderInfoList[0].refund.refundPrice }}</text>
					<text>申请时间： {{ itemObj.orderInfoList[0].refund.addTime }}</text>
				</view>
			</view>
		</view>
		<view class="sending" v-if="itemObj.refundStatus==3">
			<!-- 寄件中 -->
			<view class="q-line"></view>
			<view class="sendMsg">
				<view class="sTit">
					寄件信息
				</view>
				<view class="formBox">
					<view class="fbi">
						<text>快递公司</text>
						<text>{{ itemObj.orderInfoList[0].refund.refundExpressName }}</text>
					</view>
					<view class="fbi">
						<text>快递单号</text>
						<text>{{ itemObj.orderInfoList[0].refund.refundExpress }}</text>
						<text @click="copy(itemObj.orderInfoList[0].refund.refundExpress)">复制单号</text>
					</view>
				</view>
			</view>
		</view>
		<view class="proof" v-if="itemObj.refundStatus!=2">
			<view class="proofTit">
				退款凭证
			</view>
			<view class="scrollBox">
				<u-scroll-list :indicator="false">
					<view class="scrollItem"
						v-for="(item, index) in JSON.parse(itemObj.orderInfoList[0].refund.refundImg)" :key="index">
						<image :src="item.url"></image>
					</view>
				</u-scroll-list>
			</view>
			<view class="proofMsg c-flex-center-start">
				<text>退款原因： {{ itemObj.orderInfoList[0].refund.refundReasonWap }}</text>
				<text>退款金额： ￥{{ itemObj.orderInfoList[0].refund.refundPrice }}</text>
				<text>申请时间： {{ itemObj.orderInfoList[0].refund.addTime }}</text>
			</view>
		</view>
		<view class="btnFix" v-if="itemObj.refundStatus==1||itemObj.refundStatus==2" @click="closeShou(itemObj.id)">
			<text>撤销申请</text>
		</view>
	</view>
	<!-- 进度条 -->
	<!-- <view class="kefu">
		客服
	</view> -->
</template>
<style lang="scss">
	page {
		background-color: #fafafa;
	}

	.step1 {
		box-sizing: border-box;
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		padding: 32rpx;
		margin: 16rpx auto 0;

		.timeline {
			width: 686rpx;
			margin: 0 auto;
		}


	}

	.boxAll {
		box-sizing: border-box;
		margin: 32rpx auto;
		width: 686rpx;
		height: 240rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		padding: 32rpx;

		.con {
			width: 100%;
			height: 176rpx;
			display: flex;
			justify-content: space-between;
			align-items: flex-start;

			.conL {
				width: 176rpx;
				height: 176rpx;
			}

			.conR {
				width: 426rpx;
				display: flex;
				justify-content: space-between;
				align-items: flex-start;

				.rl {
					width: 338rpx;
					font-size: 28rpx;
				}

				.rr {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					align-items: flex-end;
					font-size: 28rpx;
				}
			}
		}

	}

	.addressInfo {
		box-sizing: border-box;
		padding: 32rpx;
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		margin: 20rpx auto;

		.addTit {
			font-size: 32rpx;
			font-weight: 600;
			color: rgba(0, 0, 0, 0.85);
		}

		.con {
			line-height: 40rpx;
			margin: 20rpx 0;
			font-size: 28rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.45);

			.conItem {
				text:nth-child(1) {
					color: #333;
				}
			}

		}

		.proofMsg {
			margin-top: 50rpx;

			text {
				font-size: 24rpx;
				font-weight: 400;
				color: #B4B4B4;
				line-height: 50rpx;
			}
		}

		.inputNum {
			text:nth-child(1) {
				font-size: 28rpx;
				font-weight: 400;
				color: #333;
			}

			text:nth-child(2) {
				width: 160rpx;
				height: 54rpx;
				line-height: 54rpx;
				text-align: center;
				display: inline-block;
				background: rgba(255, 255, 255, 0);
				border-radius: 12rpx;
				border: 2rpx solid rgba(0, 0, 0, 0.25);
				font-size: 26rpx;
				color: rgba(0, 0, 0, 0.65);
			}
		}
	}

	.proof {
		box-sizing: border-box;
		padding: 32rpx;
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		margin: 0 auto;



		.proofTit {
			margin-bottom: 32rpx;
			font-size: 32rpx;
			font-weight: 600;
			color: rgba(0, 0, 0, 0.85);
		}

		.scrollBox {
			.scrollItem {
				image {
					width: 188rpx;
					height: 188rpx;
					margin: 0 10rpx;
				}
			}
		}

		.proofMsg {
			text {
				font-size: 24rpx;
				font-weight: 400;
				color: #B4B4B4;
				line-height: 50rpx;
			}
		}
	}

	.btnFix {
		box-sizing: border-box;
		width: 100%;
		height: 120rpx;
		position: fixed;
		bottom: 0;
		left: 0;
		text-align: right;
		padding: 32rpx 32rpx;
		box-shadow: inset 0rpx 2rpx 0rpx 0rpx rgba(0, 0, 0, 0.05);

		text {
			display: inline-block;
			width: 160rpx;
			height: 64rpx;
			line-height: 64rpx;
			text-align: center;
			background: rgba(255, 255, 255, 0);
			border-radius: 12rpx;
			border: 2rpx solid rgba(0, 0, 0, 0.25);
			font-size: 28rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.65);
		}
	}

	.kefu {
		width: 100rpx;
		height: 100rpx;
		line-height: 100rpx;
		border-radius: 50rpx;
		position: fixed;
		right: 100rpx;
		bottom: 100rpx;
		border: 1rpx solid #000;
		text-align: center;
	}

	.sending {
		width: 686rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		margin: 32rpx auto;
		box-sizing: border-box;
		padding: 32rpx;

		.sendMsg {
			.sTit {
				font-size: 32rpx;
				font-weight: 600;
				color: rgba(0, 0, 0, 0.85);
			}

			.formBox {
				box-sizing: border-box;
				margin: 40rpx auto 0;

				.fbi {
					font-size: 28rpx;
					font-weight: 500;
					color: rgba(0, 0, 0, 0.85);
					line-height: 50rpx;

					text:nth-child(1) {
						margin-right: 40rpx;
					}

					text:nth-child(2) {}

					text:nth-child(3) {
						width: 128rpx;
						height: 48rpx;
						line-height: 48rpx;
						text-align: center;
						display: inline-block;
						background: rgba(255, 255, 255, 0);
						border-radius: 12rpx;
						border: 2rpx solid rgba(0, 0, 0, 0.25);
						font-size: 24rpx;
						color: rgba(0, 0, 0, 0.65);
						float: right;

					}
				}
			}
		}
	}

	.fTit {
		box-sizing: border-box;
		padding: 32rpx;
		width: 686rpx;
		height: 104rpx;
		background: #FFFFFF;
		box-shadow: 8rpx 8rpx 32rpx 0rpx rgba(0, 0, 0, 0.04);
		border-radius: 24rpx;
		border: 2rpx solid #FFFFFF;
		margin: 16rpx auto;

		text:nth-child(1) {
			font-size: 32rpx;
			font-weight: 600;
			color: rgba(0, 0, 0, 0.85);
			margin-right: 56rpx;
		}

		text:nth-child(2) {
			font-size: 32rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.85);
		}
	}
</style>